namespace stdlib
{
#include <stdlib.h>
}

#include "memmove.h"

int atoi( const char *str )
{
  return stdlib::atoi(str);
}

 void* memmove(void *s1, const void *s2, int n) 
 {
    /* note: these don't have to point to unsigned chars */
    char *p1 = (char*)s1;
    const char *p2 =(char*)s2;
    /* test for overlap that prevents an ascending copy */
    if (p2 < p1 && p1 < p2 + n) {
        /* do a descending copy */
        p2 += n;
        p1 += n;
        while (n-- != 0) 
            *--p1 = *--p2;
    } else 
        while (n-- != 0) 
            *p1++ = *p2++;
    return s1; 
 }


char* wchar2char(wchar_t *src)
{
  char string[255];  
 // char *string=(char*)malloc(wstrlen(src)+1);
  wstr2strn(string, src, wstrlen(src));
  return string;
}

wchar_t* char2wchar(const char *src)
{
  wchar_t string[255];
  //wchar_t *string=(wchar_t*)malloc(strlen(src)*2+1);
  str2wstr(string, src);
  return string;
}

int printf(const char *format, ...)
{
}

 char *(strchr)(const char *s, int c)
 {    
     while (*s != '\0' && *s != (char)c)
         s++;
     return ( (*s == c) ? (char *) s : NULL );
 }

 char *(strrchr)(const char *s, int c)
 {
     const char *last = NULL;
     /* If the character we're looking for is the terminating null,
        we just need to look for that character as there's only one
        of them in the string.  */
     if (c == '\0')
         return strchr(s, c);
     /* Loop through, finding the last match before hitting NULL.  */
     while ((s = strchr(s, c)) != NULL) {
         last = s;
         s++;
     }
     return (char *) last;
 }





